package com.object;

public enum OtaResult {
    FAIL("升级失败"),SUCCESS("升级成功"), OFFLINE("设备离线"),
    FIRMWARE_ERROR("固件类型错误"),VERSION_ERROR("软件版本错误"),
    NONE_UPGRADE("没有升级"),
    UNKNOWN_ERROR("未知错误码");



    private final String info;
    private OtaResult(String info){this.info = info;}

    public static OtaResult checkResult(byte status){
        switch(status){
            case (byte)0x01:
                return FAIL;
            case (byte)0x80:
                return SUCCESS;
            case (byte)0x81:
                return OFFLINE;
            case (byte)0x82:
                return FIRMWARE_ERROR;
            case (byte)0x83:
                return VERSION_ERROR;
            case (byte)0x00:
                return NONE_UPGRADE;
            default:
                return UNKNOWN_ERROR;
        }
    }

    public String getInfo(){
        return this.info;
    }

}
